﻿@model PaginatedList<lottery.entity.User>
@{
    ViewData["Title"] = "Index";
}
<h2>Index</h2>
<p>
    <a asp-controller="Users" asp-action="Create">create a user</a>
</p>

<form asp-action="Index" method="get" class="form-inline">
    <div class="form-group mx-sm-3 mb-2">
        <label for="searchInput" class="sr-only">Find by name: </label>
        <input id="searchInput" type="text" name="SearchString" class="form-control" value="@ViewData["currentFilter"]" placeholder="Find by name" />
    </div>
    <input type="submit" value="Search" class="btn btn-default mb-2" />
    <a asp-action="Index">Back to Full List</a>
</form>

<table class="table">
    <thead>
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.First().DisplayName)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.First().Status)
            </th>
            <th>
                <a asp-action="Index" asp-route-sortOrder="@ViewData["PublishCountSortParm"]" asp-route-currentFilter="@ViewData["CurrentFilter"]">
                    @Html.DisplayNameFor(model => model.First().PublishCount)
                </a>
            </th>
            <th>
                <a asp-action="Index" asp-route-sortOrder="@ViewData["LotteryCountSortParm"]" asp-route-currentFilter="@ViewData["CurrentFilter"]">
                    @Html.DisplayNameFor(model => model.First().LotteryCount)
                </a>
            </th>
            <th>
                <a asp-action="Index" asp-route-sortOrder="@ViewData["CreateDateSortParm"]" asp-route-currentFilter="@ViewData["CurrentFilter"]">
                    @Html.DisplayNameFor(model => model.First().CreateDate)
                </a>
            </th>
            <th>
                <a asp-action="Index" asp-route-sortOrder="@ViewData["LastLoginDateSortParm"]" asp-route-currentFilter="@ViewData["CurrentFilter"]">
                    @Html.DisplayNameFor(model => model.First().LastLoginDate)
                </a>
            </th>

            <th></th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.DisplayName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Status)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.PublishCount)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.LotteryCount)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.CreateDate)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.LastLoginDate)
            </td>
            <td>
                <a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
                <a asp-action="Details" asp-route-id="@item.Id">Details</a> |
                <a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
            </td>
        </tr>
        }
    </tbody>
</table>
@{
    var prevDisabled = !Model.HasPreviousPage ? "disabled" : "";
    var nextDisabled = !Model.HasNextPage ? "disabled" : "";
}
<a asp-action="Index"
   asp-route-sortOrder="@ViewData["CurrentSort"]"
   asp-route-page="@(Model.PageIndex - 1)"
   asp-route-currentFilter="@ViewData["CurrentFilter"]"
   class="btn btn-default @prevDisabled">
    Previous
</a>
<a asp-action="Index"
   asp-route-sortOrder="@ViewData["CurrentSort"]"
   asp-route-page="@(Model.PageIndex + 1)"
   asp-route-currentFilter="@ViewData["CurrentFilter"]"
   class="btn btn-default @nextDisabled">
    Next
</a>